﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using Microsoft.VisualStudio.Modeling.Diagrams;

namespace DSLFactory.VSCTDesigner
{
    class VisibilityContextEditor : UITypeEditor
    {
        private IWindowsFormsEditorService _edService;

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _edService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            ComboBox list = new ComboBox();
            list.Click += new EventHandler(list_Click);

            list.Items.Add("UICONTEXT_SolutionBuilding");
            list.Items.Add("UICONTEXT_Debugging");
            list.Items.Add("UICONTEXT_Dragging");
            list.Items.Add("UICONTEXT_FullScreenMode");
            list.Items.Add("UICONTEXT_DesignMode");
            list.Items.Add("UICONTEXT_NoSolution");
            list.Items.Add("UICONTEXT_SolutionExists");
            list.Items.Add("UICONTEXT_EmptySolution");
            list.Items.Add("UICONTEXT_SolutionHasSingleProject");
            list.Items.Add("UICONTEXT_SolutionHasMultipleProjects");
            list.Items.Add("UICONTEXT_CodeWindow");

            _edService.DropDownControl(list);
            if( list.SelectedIndex >= 0)
            {
                string val = (string)list.Items[list.SelectedIndex];
                return val;
            }
            return base.EditValue(context, provider, value);
        }

        void list_Click(object sender, EventArgs e)
        {
            _edService.CloseDropDown();
        }

        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.DropDown;
        }
    }
}
